/*
 * searchtree.h
 *
 *  Created on: 2011 2011-9-5 下午9:49:26
 *      Author: jfhu
 */

#ifndef SEARCHTREE_H_
#define SEARCHTREE_H_

typedef struct _node {
	int key;
	struct _node* leftChild;
	struct _node* rightChild;
	struct _node* parent;
} node, *pNode;

typedef pNode *searchtree;

void initializenode(pNode n);

void initializenode1(pNode, int key);

searchtree makesearchtree(int *array, int size);

pNode access(int key, searchtree s);

pNode visit(int key, pNode n);

void insert(pNode n, searchtree s);
void insertNode(pNode n, pNode s);

void delete(pNode n, searchtree s);
void deleteNode(pNode n, pNode s);


void printfSearchTree(searchtree s);
void printfNode(pNode s);

searchtree join(searchtree s1, pNode n, searchtree s2);

void split(pNode i, searchtree s, searchtree s1, searchtree s2);

#endif /* SEARCHTREE_H_ */
